
clear
set more off

cd ""

use "data/attitude towards capitalism.dta", clear
merge 1:1 iso year using "data/f.dta"
drop _merge

merge 1:1 iso year using "data/gdpdata.dta"
drop if _merge == 2 
drop _merge

** extrapolate surv
gsort iso year
count if !missing(surv) 
* linear
by iso: ipolate surv year, generate(surv_linear)

*** real gdp growth
tsset iso_num year
sort iso_num year

by iso_num: gen grgdppc = (rgdppc / L.rgdppc - 1)*100 
qui gen rcredit_loan = tloans/cpi
by iso_num: gen credit_growth = (rcredit_loan/ L.rcredit_loan - 1)*100

keep iso_num iso lang year score all_stdscore proc leaning surv* iso grgdppc rgdppc credit_growth 
egen country = group(iso)

eststo clear
foreach varn in leaning surv_linear proc { 
foreach cont in grgdppc { 
	eststo: xtscc all_stdscore `varn' `cont'
	eststo: xtscc all_stdscore `varn' `cont' i.year
	eststo: xtscc all_stdscore `varn' `cont' i.year, fe
}
}
*}
esttab using "output.csv", star(* 0.10 ** 0.05 *** 0.01) replace se stats(N r2 r2_w r2_a) drop(*year)

